<?php

/*
 * Argument Assertion - check if certain keys of role and resource are the same
 * 
 * Possible use when you want to check if the resource object has a user_id attribute
 * with the same value of the role object (a user object).
 *
 * The assertion object requires an array of KEY => VALUE pairs, where the KEYs refer
 * to role attributes, and VALUEs to resource attributes.
 *
 * example : new Acl_Assert_Argument(array('primary_key_value'=>'user_id'));
 */
 
class Acl_Assert_Owner implements Acl_Assert_Interface {
	
	public function __construct()
	{
		//
	}
	
	public function assert(Acl_Core $acl, $role = null, $resource = null, $privilege = null)
	{
		$res_owner_uid = $resource->owner_uid ();
		$role_uid      = $role->get_user_id   ();

		if ($role_uid == $res_owner_uid)
			return TRUE;
		else
			return FALSE;
	}
}
